#!/usr/bin/perl
# addcomm.cgi



require 'snmp-lib.pl';

#&header($text{'index_title'}, "", undef, undef, 1);
&ReadParse();
&error_setup("Add Community");

my $nameComm = $in{commName};
my $lineEntry;
if($nameComm =~ /\W\W*/)
{
	&error("invalid name input");
	&nas_syslog("snmp","naslog_warning",13015,"Add community:Invalid name($nameComm) input!");
}
else
{
	#print $nameComm,"\n";
	#print $in{aclright};
	if($in{aclright} =~ /readonly/)
	{
		$lineEntry = "rocommunity ".$nameComm;
	}
	else
	{
		$lineEntry = "rwcommunity ".$nameComm;
	}
	#print $lineEntry;
	my $code = &WriteConfFile($nameComm, $lineEntry);
	if($code)
	{
		&error("Failed!");
		&nas_syslog("snmp","naslog_warning",13016,"add community failed!");
	}
	else
	{
		
		&nas_syslog("snmp","naslog_info",13017,"add community successful!");
		&redirect("index.cgi");
	}
}

#&footer("/ucd-snmp/commadd.cgi",$text{'commadd_title'});
